package com.chandra.pos.web.customer.action;

import com.chandra.pos.dao.entity.CustomerEntity;
import com.chandra.pos.model.UserFilter;
import org.apache.struts2.interceptor.validation.SkipValidation;

import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * UserEntity: chkumar
 * Date: 5/25/12
 * Time: 12:27 PM
 * To change this template use File | Settings | File Templates.
 */
public class ListCustomerAction extends CustomerAction {

    List<CustomerEntity> userEntities;

    String term;

    List<Map> results;


    @SkipValidation
    public String doList() {
        UserFilter filter = new UserFilter(0,10);

        if (term != null)
            filter.setNameQuery(term);
        List<CustomerEntity> userEntityList = getUserManagement().searchCustomer(filter);
        this.userEntities = userEntityList;


        return SUCCESS;
    }

    public String doSuggest() {
        UserFilter filter = new UserFilter();
        if (term != null)
            filter.setNameQuery(term);
        List<CustomerEntity> userEntityList = getUserManagement().searchCustomer(filter);
        this.userEntities = userEntityList;


        return SUCCESS;
    }


    @SkipValidation
    public String doSearch() {
        UserFilter filter = new UserFilter();
        if (term != null)
            filter.setNameQuery(term);
        List<CustomerEntity> userEntityList = getUserManagement().searchCustomer(filter);
        this.userEntities = userEntityList;

        return SUCCESS;
    }

    public List<CustomerEntity> getUserEntities() {
        return userEntities;
    }


    public String getTerm() {
        return term;
    }

    public void setTerm(String term) {
        this.term = term;
    }

    public List<Map> getResults() {
        return results;
    }


}
